/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Vista;

import Validacion.ValidaCliente;
import java.awt.event.ItemEvent;
import java.util.ArrayList;
import javax.swing.JFrame;
import javax.swing.JOptionPane;
import Modelo.Cliente;
import Validacion.ValidaReJudicial;
import javax.swing.JPanel;

/**
 *
 * @author bastian
 */
public class Panel_ReJudicial extends javax.swing.JPanel {

    /**
     * Creates new form Panel_Cliente
     */
    public Panel_ReJudicial() {
        initComponents();
    }
    
    private VentanaPrincipal V_Principal;
    private Panel_ResumenRecepcion P_Resumen;
    protected ArrayList Causa;
    
    
    public void setFrame(JFrame f){
        this.V_Principal= (VentanaPrincipal) f;
        Causa = new ArrayList();
    }
    
    public void setPanel_ResumenRecepcion(JPanel p){
        P_Resumen = (Panel_ResumenRecepcion)p;
    }
    
    private void Limpiar(){
        this.TextField_ID.setText("");
        this.jTextField_Bodegaje.setText("");
        this.jTextField_Demandado.setText("");
        this.jTextField_Demandante.setText("");
        this.jDateChooser_FeDevolucion.setDate(new java.util.Date());
        this.jDateChooser_FeIngreso.setDate(null);
    
    }
    
    public ArrayList getDatos(){
        ArrayList datos = new ArrayList();
        
        datos.add(this.TextField_ID.getText());
        datos.add(this.jDateChooser_FeIngreso.getDate());
        datos.add(this.jDateChooser_FeDevolucion.getDate());
        datos.add(this.jTextField_Demandante.getText());
        datos.add(this.jTextField_Demandado.getText());
        datos.add(this.jTextField_Bodegaje.getText());
        
        return datos;
    }
    
    protected void ReJudicialNueva(boolean b){
        this.Limpiar();
        this.jButton_BuscarRecepcion.setVisible(!b);
        this.jButton_ModificarRecepcion.setVisible(!b);
        this.TextField_ID.setEditable(b);
        
        this.jDateChooser_FeIngreso.setEnabled(b);
        this.jDateChooser_FeDevolucion.setEnabled(b);
        this.jTextField_Bodegaje.setEditable(b);
        this.jTextField_Demandante.setEditable(b);
        this.jTextField_Demandado.setEditable(b);
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jDateChooser_FeDevolucion = new com.toedter.calendar.JDateChooser();
        jLabel_FeDevolucion = new javax.swing.JLabel();
        jDateChooser_FeIngreso = new com.toedter.calendar.JDateChooser();
        jLabel_FeIngreso = new javax.swing.JLabel();
        jLabel_Demandante = new javax.swing.JLabel();
        jTextField_Demandante = new javax.swing.JTextField();
        jLabel_Demandado = new javax.swing.JLabel();
        jTextField_Demandado = new javax.swing.JTextField();
        jLabel_Bodegaje = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jTextField_Bodegaje = new javax.swing.JTextField();
        jButton_Cancelar = new javax.swing.JButton();
        label_Justicia481 = new Vista.Imagenes_Label.justicia.Label_Justicia48();
        TextField_Rol = new javax.swing.JTextField();
        Label_Rol = new javax.swing.JLabel();
        jButton_BuscarRecepcion = new javax.swing.JButton();
        Label_ID = new javax.swing.JLabel();
        TextField_ID = new javax.swing.JTextField();
        jButton_ModificarRecepcion = new javax.swing.JButton();
        jButton_BuscarCausa = new javax.swing.JButton();
        jButton_AgregarProductos = new javax.swing.JButton();

        setFont(new java.awt.Font("Arial", 0, 18)); // NOI18N
        setMaximumSize(new java.awt.Dimension(1000, 550));
        setMinimumSize(new java.awt.Dimension(1000, 550));
        setName("Cliente");
        setPreferredSize(new java.awt.Dimension(1000, 550));

        jDateChooser_FeDevolucion.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jDateChooser_FeDevolucion.setMaxSelectableDate(new java.util.Date(253370779303000L));
        jDateChooser_FeDevolucion.setMinSelectableDate(new java.util.Date(1262318503000L));

        jLabel_FeDevolucion.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel_FeDevolucion.setText("Fecha Devolución");

        jDateChooser_FeIngreso.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jDateChooser_FeIngreso.setMaxSelectableDate(new java.util.Date(253370779303000L));
        jDateChooser_FeIngreso.setMinSelectableDate(new java.util.Date(1262318503000L));

        jLabel_FeIngreso.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel_FeIngreso.setText("Fecha Ingreso");

        jLabel_Demandante.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel_Demandante.setText("Demandante");

        jTextField_Demandante.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jTextField_Demandante.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField_DemandanteKeyTyped(evt);
            }
        });

        jLabel_Demandado.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel_Demandado.setText("Demandado");

        jTextField_Demandado.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jTextField_Demandado.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField_DemandadoKeyTyped(evt);
            }
        });

        jLabel_Bodegaje.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        jLabel_Bodegaje.setText("Bodegaje Pagado ($)");

        jLabel1.setFont(new java.awt.Font("Arial", 0, 36)); // NOI18N
        jLabel1.setText("Recepcion Judicial");

        jTextField_Bodegaje.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jTextField_Bodegaje.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                jTextField_BodegajeKeyTyped(evt);
            }
        });

        jButton_Cancelar.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jButton_Cancelar.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Imagenes_Files/cruz/24.png"))); // NOI18N
        jButton_Cancelar.setText("Cancelar");
        jButton_Cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_CancelarActionPerformed(evt);
            }
        });

        TextField_Rol.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        TextField_Rol.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                TextField_RolKeyTyped(evt);
            }
        });

        Label_Rol.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        Label_Rol.setText("ROL Causa");

        jButton_BuscarRecepcion.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jButton_BuscarRecepcion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Imagenes_Files/buscar/24.png"))); // NOI18N
        jButton_BuscarRecepcion.setText("Buscar");

        Label_ID.setFont(new java.awt.Font("Arial", 1, 14)); // NOI18N
        Label_ID.setText("ID Recepción");

        TextField_ID.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N

        jButton_ModificarRecepcion.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jButton_ModificarRecepcion.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Imagenes_Files/modificar/documentos/24.png"))); // NOI18N
        jButton_ModificarRecepcion.setText("Modificar");

        jButton_BuscarCausa.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jButton_BuscarCausa.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Imagenes_Files/buscar/24.png"))); // NOI18N
        jButton_BuscarCausa.setText("Buscar");

        jButton_AgregarProductos.setFont(new java.awt.Font("Arial", 0, 14)); // NOI18N
        jButton_AgregarProductos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Vista/Imagenes_Files/producto/24.png"))); // NOI18N
        jButton_AgregarProductos.setText("Añadir Productos");
        jButton_AgregarProductos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton_AgregarProductosActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(label_Justicia481, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(209, 209, 209)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(Label_Rol)
                                        .addGap(35, 35, 35)
                                        .addComponent(TextField_Rol, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(Label_ID)
                                        .addGap(18, 18, 18)
                                        .addComponent(TextField_ID)))
                                .addGap(18, 18, 18)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addGroup(layout.createSequentialGroup()
                                        .addComponent(jButton_BuscarRecepcion)
                                        .addGap(18, 18, 18)
                                        .addComponent(jButton_ModificarRecepcion))
                                    .addComponent(jButton_BuscarCausa)))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel_FeIngreso)
                                .addGap(85, 85, 85)
                                .addComponent(jLabel_FeDevolucion)
                                .addGap(38, 38, 38)
                                .addComponent(jLabel_Bodegaje))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jDateChooser_FeIngreso, javax.swing.GroupLayout.PREFERRED_SIZE, 126, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(60, 60, 60)
                                .addComponent(jDateChooser_FeDevolucion, javax.swing.GroupLayout.PREFERRED_SIZE, 127, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(38, 38, 38)
                                .addComponent(jTextField_Bodegaje, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel_Demandante)
                            .addComponent(jLabel_Demandado)
                            .addComponent(jTextField_Demandante, javax.swing.GroupLayout.PREFERRED_SIZE, 496, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jTextField_Demandado, javax.swing.GroupLayout.PREFERRED_SIZE, 496, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 242, Short.MAX_VALUE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton_AgregarProductos, javax.swing.GroupLayout.PREFERRED_SIZE, 195, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jButton_Cancelar)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addGap(67, 67, 67)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(Label_ID)
                            .addComponent(TextField_ID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jButton_BuscarRecepcion)
                            .addComponent(jButton_ModificarRecepcion)))
                    .addComponent(label_Justicia481, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(21, 21, 21)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(TextField_Rol, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(Label_Rol)
                    .addComponent(jButton_BuscarCausa))
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel_FeIngreso)
                    .addComponent(jLabel_FeDevolucion)
                    .addComponent(jLabel_Bodegaje))
                .addGap(6, 6, 6)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jTextField_Bodegaje, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(6, 6, 6)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jDateChooser_FeIngreso, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jDateChooser_FeDevolucion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addGap(18, 18, 18)
                .addComponent(jLabel_Demandante)
                .addGap(6, 6, 6)
                .addComponent(jTextField_Demandante, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(jLabel_Demandado)
                .addGap(6, 6, 6)
                .addComponent(jTextField_Demandado, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 86, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton_Cancelar)
                    .addComponent(jButton_AgregarProductos))
                .addContainerGap())
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jButton_BuscarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_BuscarActionPerformed
        // TODO add your handling code here:
        V_Principal.addPanel_Busqueda_Cliente(1);
    }//GEN-LAST:event_jButton_BuscarActionPerformed

    private void jTextField_DemandanteKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField_DemandanteKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if ((!Character.isWhitespace(c)
                && !Character.isLetter(c)) || this.jTextField_Demandante.getText().length() > 100) {
            evt.consume();
        }
    }//GEN-LAST:event_jTextField_DemandanteKeyTyped

    private void jTextField_DemandadoKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField_DemandadoKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if ((!Character.isWhitespace(c)
                && !Character.isLetter(c)) || this.jTextField_Demandado.getText().length() > 100) {
            evt.consume();
        }
    }//GEN-LAST:event_jTextField_DemandadoKeyTyped

    private void jTextField_BodegajeKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_jTextField_BodegajeKeyTyped
        // TODO add your handling code here:
        char c = evt.getKeyChar();
        if (!Character.isDigit(c) || this.jTextField_Bodegaje.getText().length() > 10) {
            evt.consume();
        }
    }//GEN-LAST:event_jTextField_BodegajeKeyTyped

    private void jButton_CancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_CancelarActionPerformed
        // TODO add your handling code here:
        this.Limpiar();
        V_Principal.desbloquearPanel();
        V_Principal.removePanel(this);
        
    }//GEN-LAST:event_jButton_CancelarActionPerformed

    private void TextField_RolKeyTyped(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_TextField_RolKeyTyped
        // TODO add your handling code here:
    }//GEN-LAST:event_TextField_RolKeyTyped

    private void jButton_AgregarProductosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_AgregarProductosActionPerformed
        // TODO add your handling code here:
        
        //REVISAR SI YA EXISTE LA RECEPCION
        if(ValidaReJudicial.ReJucicialValida(this.getDatos())){
            this.Causa.add(this.TextField_ID.getText());
            this.P_Resumen.LaCausa = this.Causa;
            this.P_Resumen.LaRecepcion = this.getDatos();
            this.P_Resumen.esJudicial();
            this.P_Resumen.Inicializar();
            this.V_Principal.addPanel_ResumenRecepcion(true);
            V_Principal.bloquearPanel(1);
        }
        
        else
            JOptionPane.showMessageDialog(V_Principal, "Datos Incorrectos", "Error", JOptionPane.ERROR_MESSAGE);
    }//GEN-LAST:event_jButton_AgregarProductosActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel Label_ID;
    private javax.swing.JLabel Label_Rol;
    private javax.swing.JTextField TextField_ID;
    protected javax.swing.JTextField TextField_Rol;
    private javax.swing.JButton jButton_AgregarProductos;
    private javax.swing.JButton jButton_BuscarCausa;
    private javax.swing.JButton jButton_BuscarRecepcion;
    private javax.swing.JButton jButton_Cancelar;
    private javax.swing.JButton jButton_ModificarRecepcion;
    private com.toedter.calendar.JDateChooser jDateChooser_FeDevolucion;
    private com.toedter.calendar.JDateChooser jDateChooser_FeIngreso;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel_Bodegaje;
    private javax.swing.JLabel jLabel_Demandado;
    private javax.swing.JLabel jLabel_Demandante;
    private javax.swing.JLabel jLabel_FeDevolucion;
    private javax.swing.JLabel jLabel_FeIngreso;
    private javax.swing.JTextField jTextField_Bodegaje;
    private javax.swing.JTextField jTextField_Demandado;
    private javax.swing.JTextField jTextField_Demandante;
    private Vista.Imagenes_Label.justicia.Label_Justicia48 label_Justicia481;
    // End of variables declaration//GEN-END:variables
}
